import { defineStore } from 'pinia'

export const useOnsiteSurveyStore = defineStore(({
    id:'onsiteSurvey',
    state: () => ({
        data:[
            {
              id: 1,
              name: 'xxxx美宜佳小区',
              region: ['440000', '440100', '440106'],
              type: '商品房',
              buildYear: '2015',
              renovation: '无',
              buildings: [
                { buildingNo: '1号楼', unitCount: 2, buildYear: '2005', floorCount: 18, population: 120, elderPopulation: 15 },
                { buildingNo: '2号楼', unitCount: 1, buildYear: '2005', floorCount: 12, population: 80, elderPopulation: 8 }
              ],
              regionText: 'xxxxxxxxxxxxxxxxxxxx',
              address: 'xxxxxxxxxxxxxxxx'
            },{
              id: 2,
              name: 'xxxx旺达小区',
              region: ['440000', '440100', '440105'],
              type: '商品房',
              buildYear: '2018',
              renovation: '无',
              buildings: [      
                { buildingNo: '1号楼', unitCount: 2, buildYear: '2005', floorCount: 18, population: 120, elderPopulation: 15 },
                { buildingNo: '2号楼', unitCount: 1, buildYear: '2005', floorCount: 12, population: 80, elderPopulation: 8 }
              ],
              regionText: 'xxxxxxxxxxxxxxxxxxxx',
              address: 'xxxxxxxxxxxxxxxx'
            },{
              id: 3,
              name: 'xxxx美名小区',
              region: ['440000', '440100', '440103'],
              type: '商品房',
              buildYear: '2025',
              renovation: '无',
              buildings: [      
                { buildingNo: '1号楼', unitCount: 2, buildYear: '2005', floorCount: 18, population: 120, elderPopulation: 15 },
                { buildingNo: '2号楼', unitCount: 1, buildYear: '2005', floorCount: 12, population: 80, elderPopulation: 8 }
              ],
              regionText: 'xxxxxxxxxxxxxxxxx',
              address: 'xxxxxxxxxxxxxxxx'
            },{
              id: 4,
              name: 'xxxx美名小区',
              region: ['440000', '440100', '440102'],
              type: '商品房',
              buildYear: '2012',
              renovation: '无',
              buildings: [      
                { buildingNo: '1号楼', unitCount: 2, buildYear: '2005', floorCount: 18, population: 120, elderPopulation: 15 },
                { buildingNo: '2号楼', unitCount: 1, buildYear: '2005', floorCount: 12, population: 80, elderPopulation: 8 }
              ],
              regionText: 'xxxxxxxxxxxxxx',
              address: 'xxxxxxxxxxxxxxxx'
            },{
              id: 5,
              name: 'xxxx美名1小区',
              region: ['440000', '440100', '440107'],
              type: '商品房',
              buildYear: '2024',
              renovation: '无',
              buildings: [      
                { buildingNo: '1号楼', unitCount: 2, buildYear: '2005', floorCount: 18, population: 120, elderPopulation: 15 },
                { buildingNo: '2号楼', unitCount: 1, buildYear: '2005', floorCount: 12, population: 80, elderPopulation: 8 }
              ],
              regionText: 'xxxxxxxxxxxxxxxx',
              address: 'xxxxxxxxxxxxxxxx'
            },{
              id: 6,
              name: 'xxxx美宜佳小区',
              region: ['440000', '440100', '440108'],
              type: '商品房',
              buildYear: '2012',
              renovation: '无',   
              buildings: [      
                { buildingNo: '1号楼', unitCount: 2, buildYear: '2005', floorCount: 18, population: 120, elderPopulation: 15 },
                { buildingNo: '2号楼', unitCount: 1, buildYear: '2005', floorCount: 12, population: 80, elderPopulation: 8 }
              ],
              regionText: 'xxxxxxxxxxxxxxxxxxx',
              address: 'xxxxxxxxxxxxxxxx' 
            },{
              id: 7,
              name: 'xxxx美宜佳小区',
              region: ['440000', '440100', '440109'],
              type: '商品房',
              buildYear: '2018',
              renovation: '无',
              buildings: [      
                { buildingNo: '1号楼', unitCount: 2, buildYear: '2005', floorCount: 18, population: 120, elderPopulation: 15 },
                { buildingNo: '2号楼', unitCount: 1, buildYear: '2005', floorCount: 12, population: 80, elderPopulation: 8 }
              ],
              regionText: 'xxxxxxxxxxxxxxxxx',
              address: 'xxxxxxxxxxxxxxxx'     
            },{
              id: 8,
              name: 'xxxx美宜佳小区112',
              region: ['440000', '440100', '440111'],
              type: '商品房',
              buildYear: '2012',    
              renovation: '无',
              buildings: [      
                { buildingNo: '1号楼', unitCount: 2, buildYear: '2005', floorCount: 18, population: 120, elderPopulation: 15 },
                { buildingNo: '2号楼', unitCount: 1, buildYear: '2005', floorCount: 12, population: 80, elderPopulation: 8 }
              ],
              regionText: 'xxxxxxxxxxxxxxxxx',   
              address: 'xxxxxxxxxxxxxxxx'
            },{
              id: 9,
              name: 'xxxx美宜佳小区小书',
              region: ['440000', '440100', '440112'],
              type: '商品房', 
              buildYear: '2012',
              renovation: '无',
              buildings: [      
                { buildingNo: '1号楼', unitCount: 2, buildYear: '2005', floorCount: 18, population: 120, elderPopulation: 15 },
                { buildingNo: '2号楼', unitCount: 1, buildYear: '2005', floorCount: 12, population: 80, elderPopulation: 8 }
              ],  
              regionText: 'xxxxxxxxxxxxxxxxxxx',
              address: 'xxxxxxxxxxxxxxxx'
            }
          ],
    }),
    getters: {
        getData: (state) => state.data,
    },
    actions: {
        CHANGE_PROPERTY({ key, value }: { key: any, value: any }) {
            if (Reflect.has(this, key)) {
              this[key] = value as any;
            }
          },
        change(data:any) {
         this.CHANGE_PROPERTY(data);
        },
    }
}))

